package website.digitalocean.chapter9;

import java.sql.Connection;

/**
 * @author: longhc@citycloud.com.cn
 * @since: 2023/2/10 16:28
 * @version: 1.0
 */
public class HelperFacade {

    public static void generateReport(DbType dbType, ReportTypes reportTypes, String table) {
        Connection connection = null;
        switch (dbType) {
            case MYSQL:
                connection = MySqlHelper.connection();
                MySqlHelper mySqlHelper = new MySqlHelper();
                switch (reportTypes) {
                    case HTML:
                        mySqlHelper.generateMySqlHtmlReport(table, connection);
                        break;
                    case PDF:
                        mySqlHelper.generateMySqlPdfReport(table, connection);
                        break;
                    default:
                        break;
                }
                break;
            case ORACLE:
                connection = OracleHelper.connection();
                OracleHelper oracleHelper = new OracleHelper();
                switch (reportTypes) {
                    case HTML:
                        oracleHelper.generateOracleHtmlReport(table, connection);
                        break;
                    case PDF:
                        oracleHelper.generateOraclePdfReport(table, connection);
                        break;
                    default:
                        break;
                }
                break;
            default:
                break;
        }
    }

    public static enum DbType {
        MYSQL, ORACLE;
    }

    public static enum ReportTypes {
        HTML, PDF;
    }
}
